import React, { Component } from 'react'

export default class State extends Component {
    // constructor() {
    //     super()
    //     this.state = {
    //         count: 100
    //     }
    // }
    state = {
        count: 200
    }
    // 在react类组件中想要让视图进行更新，必须重新执行render函数
    render() {
        const { count } = this.state
        // console.log('render执行了')
        return (
            <div>
                State -- { count }
                <button onClick = { () => {
                    // this.state.count += 1
                    // console.log(this.state.count)
                    this.setState({
                        count: 500
                    }, () => {
                        // console.log("数据修改完毕")
                        console.log(this.state.count)
                    })

                    
                } }>点我</button>
            </div>
        )
    }
}
